package debugs;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletResponse;

import models.OrderModel;

public class OrderDebug {
	public static void debug(OrderModel order) {
		try {
			System.out
					.println("-------------------------------------------------------------");
			for (Field f : order.getClass().getDeclaredFields()) {
				f.setAccessible(true);
				System.out.print(f.getName());
				System.out.print(": ");
				System.out.print(f.get(order));
				System.out.print("- ");
				System.out.print(f.getType().getSimpleName());
				System.out.println("");
			}
			System.out
					.println("-------------------------------------------------------------");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void debugWeb(OrderModel order, HttpServletResponse response) {
		try {
			response.getWriter()
					.println(
							"-------------------------------------------------------------");
			for (Field f : order.getClass().getDeclaredFields()) {
				f.setAccessible(true);
				response.getWriter().print(f.getName());
				response.getWriter().print(": ");
				response.getWriter().print(f.get(order));
				response.getWriter().println("");
			}
			response.getWriter()
					.println(
							"-------------------------------------------------------------");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
